﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web.Services;

namespace Agile.Engine.Service
{
    /// <summary>
    /// 服务契约接口
    /// </summary>
    public interface IWebServiceProxy
    {
        /// <summary>
        /// 执行服务
        /// </summary>
        /// <param name="args"></param>
        /// <returns></returns>
        string InvokeService(string args);
    }

    [WebService(Namespace = "http://agile.engine/services")]
    public class WebServiceProxy : IWebServiceProxy
    {
        [WebMethod(EnableSession = true)]
        public virtual string InvokeService(string args)
        {
            var key = "DefaultTaskAllocator";
            Allocator = Spring.Context.Support.ContextRegistry.GetContext().GetObject(key) as ITaskAllocator;
            return Allocator.Allocation(args);
        }

        /// <summary>
        /// 任务分配器
        /// </summary>
        ITaskAllocator Allocator { get; set; }

    }

}
